package com.contour.util;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;

public class DateFormatter {
	private static final String XML_DATE_PATTERN = "yyyy-MM-dd'T'HH:mm:ss";
	private static final String DATE_PATTERN_US = "MM-dd-yyyy";
	private static final String SIMPLE_DATE_PATTERN_TIMESTAMP = "MMddyyyy-HH:mm:ss";
	private static final String DISPLAY_DATE_PATTERN_TIMESTAMP = "MMM d, yyyy-h:mm a";

	public static DateFormat getXmlDateFormat() {
		DateFormat df = SimpleDateFormat.getInstance();
		((SimpleDateFormat) df).applyPattern(XML_DATE_PATTERN);
		return df;
	}

	public static String getXmlDate(Date date) {
		DateFormat df = getXmlDateFormat();
		return df.format(date);
	}

	public static DateFormat getDateFormatUS() {
		DateFormat df = SimpleDateFormat.getInstance();
		((SimpleDateFormat) df).applyPattern(DATE_PATTERN_US);
		return df;
	}

	public static String getUSDate(Date date) {
		DateFormat df = getDateFormatUS();
		return df.format(date);
	}

	public static DateFormat getSimpleDateFormatTimestamp() {
		DateFormat df = SimpleDateFormat.getInstance();
		((SimpleDateFormat) df).applyPattern(SIMPLE_DATE_PATTERN_TIMESTAMP);
		return df;
	}

	public static String getSimpleDateTimestamp(Date date) {
		DateFormat df = getSimpleDateFormatTimestamp();
		return df.format(date);
	}

	public static DateFormat getDisplayDateFormatTimestamp() {
		DateFormat df = SimpleDateFormat.getInstance();
		((SimpleDateFormat) df).applyPattern(DISPLAY_DATE_PATTERN_TIMESTAMP);
		return df;
	}

	public static String getDisplayDateTimestamp(Date date) {
		DateFormat df = getDisplayDateFormatTimestamp();
		return df.format(date);
	}

}
